<html>
<head><meta charset="utf-8"><title>Tips to improve compile times within a crate? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html">Tips to improve compile times within a crate?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203906801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203906801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203906801">(Jul 15 2020 at 01:00)</a>:</h4>
<p>We're often encouraged to break big crates into smaller crates and spread around the build parallelism as much as we can. However, it's not always possible to just break up a crate like that.</p>
<p>Are there any tips to increase build speed when the crate is 70,000 lines and not getting any smaller? Does it help to have more modules? Less modules? <code>cfg</code> things out? Cut down on <code>cfg</code> and just build it all? Sacrifice a chicken?</p>



<a name="203906937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203906937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203906937">(Jul 15 2020 at 01:03)</a>:</h4>
<p>modules shouldn't matter (<em>grumbles at CGUs</em>), you could run <code>cargo rustc -- -Z self-profile</code> and see what it says</p>



<a name="203906995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203906995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203906995">(Jul 15 2020 at 01:04)</a>:</h4>
<p>("see what it says" requiring <code>cargo install --git https://github.com/rust-lang/measureme summarize crox</code> - <code>summarize</code> gives you a basic report, <code>crox</code> gives you a file you can load into Chrome DevTools for a detailed view)</p>



<a name="203907010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907010">(Jul 15 2020 at 01:04)</a>:</h4>
<p>the answer is quite dependent on what the compiler is doing</p>



<a name="203907124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907124">(Jul 15 2020 at 01:06)</a>:</h4>
<p>oh and if you're willing to play around, there's a way to make the <code>crox</code> output even more tailed, referring to the relevant parts of your crate (but this is mostly useful when there's an outlier that takes 10x-100x more than the average etc.)</p>



<a name="203907153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907153">(Jul 15 2020 at 01:07)</a>:</h4>
<p>Well it's for GL binding. There's two ways of loading ~600 functions, and then all the eums. It adds up to 2.45mb of source. <a href="https://raw.githubusercontent.com/Lokathor/gl46/main/src/lib.rs">https://raw.githubusercontent.com/Lokathor/gl46/main/src/lib.rs</a> if you want to look, but don't open it on your phone it'll probably crash your phone's browser, they don't handle multi-megabyte files that well.</p>



<a name="203907208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907208">(Jul 15 2020 at 01:08)</a>:</h4>
<p>600 independent things shouldn't be too slow</p>



<a name="203907222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907222">(Jul 15 2020 at 01:08)</a>:</h4>
<p>the reason I bring up <code>-Z self-profile</code> is that while some things can be eyeballed, you can't know for sure until you check</p>



<a name="203907231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907231">(Jul 15 2020 at 01:08)</a>:</h4>
<p>for all we know you could've hit some edge case we never considered</p>



<a name="203907247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907247">(Jul 15 2020 at 01:09)</a>:</h4>
<p>i will tackle the current GL generator bug and then do that check, one moment.</p>



<a name="203907252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907252">(Jul 15 2020 at 01:09)</a>:</h4>
<p>although looking at the code, there's a  lot of macro-generated code</p>



<a name="203907258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907258">(Jul 15 2020 at 01:09)</a>:</h4>
<p>which is always a trade-off</p>



<a name="203907260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907260">(Jul 15 2020 at 01:09)</a>:</h4>
<p>if possible you might want to wrap common parts in generics</p>



<a name="203907319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907319">(Jul 15 2020 at 01:10)</a>:</h4>
<p>I had thought that i'd compacted it down about as much as i could</p>



<a name="203907320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907320">(Jul 15 2020 at 01:10)</a>:</h4>
<p>relying on monomorphization can be a a big speedup since while the LLVM IR generated is more or less the same, all the high-level type-checking and whatnot is done only once</p>



<a name="203907328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907328">(Jul 15 2020 at 01:10)</a>:</h4>
<p>I'm seeing a lot of repetitions between functions, <code>trace!</code> looks pretty suspicious for example, but maybe that's off by default</p>



<a name="203907342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907342">(Jul 15 2020 at 01:11)</a>:</h4>
<p>ah, yes, well that is off by default, or it can expand to println, or it can expand all the way to log::trace</p>



<a name="203907402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907402">(Jul 15 2020 at 01:12)</a>:</h4>
<p>the <code>match f(x) { Some(y) =&gt; ..., None =&gt; ...  }</code> could probably be moved into a wrapper for <code>f</code></p>



<a name="203907419"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907419" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907419">(Jul 15 2020 at 01:12)</a>:</h4>
<p>one neat trick is that while Rust doesn't have VG, you are generating this, so you could just have one wrapper per argument count</p>



<a name="203907421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907421">(Jul 15 2020 at 01:12)</a>:</h4>
<p>so that even parsing the initial code, pre-expansion, is really fast</p>



<a name="203907439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907439">(Jul 15 2020 at 01:13)</a>:</h4>
<p>apropos of nothing, <code>inline</code> and <code>inline_always</code> look like they'd conflict, you probably want to pick the stronger of the two if they're both on</p>



<a name="203907501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907501">(Jul 15 2020 at 01:14)</a>:</h4>
<p>there's stuff like <code>if "glObjectPtrLabel" != "glGetError" {</code> which looks like it could be pre-evaluated in the generator</p>



<a name="203907503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907503">(Jul 15 2020 at 01:14)</a>:</h4>
<p>i checked and they don't conflict, but also the reference doesn't even say what happens, you probably get the always</p>



<a name="203907508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907508">(Jul 15 2020 at 01:14)</a>:</h4>
<p>haha oops</p>



<a name="203907511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907511">(Jul 15 2020 at 01:14)</a>:</h4>
<p>I should've checked before saying anything</p>



<a name="203907521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907521">(Jul 15 2020 at 01:14)</a>:</h4>
<p>and yes, suppose that i could eval that bit within the generator :(</p>



<a name="203907527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907527">(Jul 15 2020 at 01:15)</a>:</h4>
<p>anyway I doubt most of my suggestions will make a huge dent</p>



<a name="203907536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907536">(Jul 15 2020 at 01:15)</a>:</h4>
<p>I'm really curious what the timings look like on this</p>



<a name="203907537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907537">(Jul 15 2020 at 01:15)</a>:</h4>
<p>okay i made some timings info</p>



<a name="203907540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907540">(Jul 15 2020 at 01:15)</a>:</h4>
<p>how long does <code>cargo check</code> take?</p>



<a name="203907553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907553">(Jul 15 2020 at 01:16)</a>:</h4>
<p>6.27s, with all features on.</p>



<a name="203907596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907596">(Jul 15 2020 at 01:16)</a>:</h4>
<p>and without?</p>



<a name="203907617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907617">(Jul 15 2020 at 01:16)</a>:</h4>
<p>if we turn it to just the struct loader, 2.17s</p>



<a name="203907662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907662">(Jul 15 2020 at 01:17)</a>:</h4>
<p>so now the question is whether you want to bring down the 2s or the delta of 4s</p>



<a name="203907665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907665">(Jul 15 2020 at 01:17)</a>:</h4>
<p>uh, how the heck do i use any of this self profile data &gt;_&gt; it seems to have made 3 binary files that VS Code doesn't have the slightest idea about</p>



<a name="203907677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907677">(Jul 15 2020 at 01:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F/near/203906995">said</a>:</p>
<blockquote>
<p>("see what it says" requiring <code>cargo install --git https://github.com/rust-lang/measureme summarize crox</code> - <code>summarize</code> gives you a basic report, <code>crox</code> gives you a file you can load into Chrome DevTools for a detailed view)</p>
</blockquote>
<p>^^</p>



<a name="203907726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907726">(Jul 15 2020 at 01:18)</a>:</h4>
<p>oh that's the file reader<br>
i thought that was a secondary way to get timings.</p>



<a name="203907727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907727">(Jul 15 2020 at 01:18)</a>:</h4>
<p>we could have <code>rustc</code> autogenerate a basic report, but there was opposition to it :(</p>



<a name="203907735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907735">(Jul 15 2020 at 01:18)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="125250">@Wesley Wiser</span></p>



<a name="203907743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907743">(Jul 15 2020 at 01:18)</a>:</h4>
<p>(the reason it's a compact binary format is that we want as low overhead as possible)</p>



<a name="203907748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907748">(Jul 15 2020 at 01:19)</a>:</h4>
<p>hey, only 81 deps! this is pretty slim for something via cargo install!</p>



<a name="203907835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907835">(Jul 15 2020 at 01:21)</a>:</h4>
<p><a href="https://gist.github.com/rust-play/5b353916e89d3d90ae5926d2a28d1c1f">https://gist.github.com/rust-play/5b353916e89d3d90ae5926d2a28d1c1f</a></p>



<a name="203907899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907899">(Jul 15 2020 at 01:22)</a>:</h4>
<p>wow, self-contained self time</p>



<a name="203907912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907912">(Jul 15 2020 at 01:23)</a>:</h4>
<p>how do you end up with 6k things to typeck, didn't you say it's 600?</p>



<a name="203907962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907962">(Jul 15 2020 at 01:24)</a>:</h4>
<p>~600 <em>functions</em>, and then two loaders, so that's like 1200 to 1300 functions, and then there's a bazillion enumerations (<code>const</code> in rust terms).</p>



<a name="203907969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907969">(Jul 15 2020 at 01:24)</a>:</h4>
<p>I guess it's 600*3 just to start</p>



<a name="203907975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907975">(Jul 15 2020 at 01:24)</a>:</h4>
<p>3? where's 3 from?</p>



<a name="203907977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907977">(Jul 15 2020 at 01:24)</a>:</h4>
<p>(there's also <code>_is_loaded</code>)</p>



<a name="203907998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203907998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203907998">(Jul 15 2020 at 01:25)</a>:</h4>
<p>oh, yes, and well there's also the loader function too, so 6 functions per command and over 600 commands, i guess that adds up fast</p>



<a name="203908011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908011">(Jul 15 2020 at 01:25)</a>:</h4>
<p>anyway, you have a lot of things that are like eachother - so you ideally want to lower the factor (of cost per each of those things)</p>



<a name="203908020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908020">(Jul 15 2020 at 01:25)</a>:</h4>
<p>my suggestion would be to bin them into arity and then use generics as much as possible</p>



<a name="203908083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908083">(Jul 15 2020 at 01:26)</a>:</h4>
<p>and that would make compile time go <em>down</em>? I thought the expansion time would go up because of the monomorphization time? Also, not only arity but fn arg type matters here</p>



<a name="203908089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908089">(Jul 15 2020 at 01:27)</a>:</h4>
<p>monomorphization is cheaper than type-checking</p>



<a name="203908090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908090">(Jul 15 2020 at 01:27)</a>:</h4>
<p>idk who's saying otherwise</p>



<a name="203908096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908096">(Jul 15 2020 at 01:27)</a>:</h4>
<p>no one said otherwise, but people do talk about monomorph time and no one talks about type check time :P</p>



<a name="203908098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908098">(Jul 15 2020 at 01:27)</a>:</h4>
<p>monomorphization is basically free, the total cost is in the number of instances, which would remain unchanged</p>



<a name="203908101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908101">(Jul 15 2020 at 01:27)</a>:</h4>
<p>type-checking similar code, is not</p>



<a name="203908103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908103">(Jul 15 2020 at 01:27)</a>:</h4>
<p>(since we have no way of knowing it's similar)</p>



<a name="203908142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908142">(Jul 15 2020 at 01:28)</a>:</h4>
<p>and there is no "expansion time"</p>



<a name="203908144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908144">(Jul 15 2020 at 01:28)</a>:</h4>
<p><code>expand_crate</code> is macro expansion</p>



<a name="203908150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908150">(Jul 15 2020 at 01:28)</a>:</h4>
<p>basically it's always cheaper to instantiate one generic function N times than have N functions</p>



<a name="203908158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908158">(Jul 15 2020 at 01:28)</a>:</h4>
<p>huh, well okay</p>



<a name="203908160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908160">(Jul 15 2020 at 01:28)</a>:</h4>
<p>the instantiation is "free" because it's part of MIR -&gt; LLVM IR</p>



<a name="203908175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908175">(Jul 15 2020 at 01:29)</a>:</h4>
<p>most of the other front-end stuff doesn't get deduplicated (trait system stuff like searching for matching impls being an exception, but that's arguably pretty deep in the compiler)</p>



<a name="203908224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908224">(Jul 15 2020 at 01:30)</a>:</h4>
<p>this makes me feel like we're not messaging things too well :(</p>



<a name="203908242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908242">(Jul 15 2020 at 01:30)</a>:</h4>
<p>with respect, i'd say that you're not messaging things at all. There's only one main thing about compile times that I can recall anyone posting, and it's by Icefox, who I know doesn't work on any part of the compiler at all</p>



<a name="203908254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908254">(Jul 15 2020 at 01:31)</a>:</h4>
<p>also, abstractions can be "free" if the data types involved are integers/floats/pointers (or pairs thereof), including anything that's just structs around those, LLVM only really has to come in and optimize stuff away once you have larger data being moved/copied around</p>



<a name="203908268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908268">(Jul 15 2020 at 01:31)</a>:</h4>
<p>sure, I'm pretty deep in my corner and don't even get to interact with a lot of the community nowadays, so it wouldn't be me specifically (and I probably wouldn't even know about it)</p>



<a name="203908294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908294">(Jul 15 2020 at 01:32)</a>:</h4>
<p>just saying that it's more thing to be sad about</p>



<a name="203908328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908328">(Jul 15 2020 at 01:32)</a>:</h4>
<p>anyway there's an extreme solution and I want to sketch it out (it might not be hard to test, and if it's a big enough win you might get away with using it)</p>



<a name="203908343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908343">(Jul 15 2020 at 01:33)</a>:</h4>
<p>I will await that, and in the async time i will edit the generator to eliminate that if that compares two string literals</p>



<a name="203908344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908344">(Jul 15 2020 at 01:33)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="n">glAttachShader</span>: <span class="nc">Fn2</span><span class="o">&lt;</span><span class="n">GLuint</span><span class="p">,</span><span class="w"> </span><span class="n">GLuint</span><span class="p">,</span><span class="w"> </span><span class="p">()</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"></span>
<span class="w">    </span><span class="n">Fn2</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">name</span>: <span class="s">&quot;glAttachShader&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">c_name</span>: <span class="nc">b</span><span class="s">&quot;glAttachShader</span><span class="se">\0</span><span class="s">&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">_marker</span>: <span class="nc">PhantomData</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
</code></pre></div>



<a name="203908393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908393">(Jul 15 2020 at 01:34)</a>:</h4>
<p>and then all of the functionality is on the <code>struct</code></p>



<a name="203908415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908415">(Jul 15 2020 at 01:35)</a>:</h4>
<p>to expand a bit on what I was saying earlier: typeck and borrowck are roughly proportional in the source code (after macro expansion), whereas codegen/LLVM optimizations is somewhat similar but anything generic is multiplied by the number of instances</p>



<a name="203908426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908426">(Jul 15 2020 at 01:35)</a>:</h4>
<p>so if you want to reduce <code>cargo check</code> time, you want to compact your code (but not with macros, since those offer no work deduplication opportunities)</p>



<a name="203908500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908500">(Jul 15 2020 at 01:36)</a>:</h4>
<p>one downside with that approach is AFAIK there's no way to make call operators work (as you can't implement the <code>Fn</code> traits yourself), so you might still need a wrapper that calls a method on the value which actually does the work</p>



<a name="203908534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908534">(Jul 15 2020 at 01:37)</a>:</h4>
<p>there might be a way to use <code>Deref</code>, but it seems iffy, as you would need to be storing the pointer at a memory address, and it would... oh no it wouldn't</p>



<a name="203908544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908544">(Jul 15 2020 at 01:37)</a>:</h4>
<p>'sec, lemme do a demo,  this might be a novel call operator hack</p>



<a name="203908638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908638">(Jul 15 2020 at 01:39)</a>:</h4>
<p>so one thing i perhaps should mention: The two loaders: one stores each fn pointer in a static AtomicPtr and the other stores them in fields of a struct, but also as AtomicPtr just for consistency sake.</p>



<a name="203908645"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908645" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908645">(Jul 15 2020 at 01:39)</a>:</h4>
<p>if that <em>somehow</em> affects your plan</p>



<a name="203908660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908660">(Jul 15 2020 at 01:39)</a>:</h4>
<p>they're not the function that you'd want to run when you go <code>glAttachShader(...)</code> so I don't think it makes a difference</p>



<a name="203908727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908727">(Jul 15 2020 at 01:40)</a>:</h4>
<p>oh nevermind my <code>Deref</code> idea doesn't work unless you can pass the name of the function as a generic parameter (const generics, or just an associated const on a type)</p>



<a name="203908917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908917">(Jul 15 2020 at 01:44)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> this is the hack btw <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=89b79cafcbf699bf03efcf1a1af35b2c">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=89b79cafcbf699bf03efcf1a1af35b2c</a></p>



<a name="203908947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203908947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203908947">(Jul 15 2020 at 01:45)</a>:</h4>
<p>I see that it works, but i'm not sure how it helps</p>



<a name="203909012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909012">(Jul 15 2020 at 01:46)</a>:</h4>
<p>it would be implemented on <code>Fn1</code>, <code>Fn2</code>, ... (all the arity wrappers for the <code>const</code>s), but it can't really work since like I said the name would have to be passed through generics</p>



<a name="203909039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909039">(Jul 15 2020 at 01:47)</a>:</h4>
<p>(probably more than the name, now that I think about it, I should gist your code so I can read it, it's hard w/o syntax highlighting)</p>



<a name="203909057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909057">(Jul 15 2020 at 01:47)</a>:</h4>
<p>the <code>Deref</code> trick is more of a novelty than useful tbh</p>



<a name="203909075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909075">(Jul 15 2020 at 01:48)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> anyway the more immediately useful stuff is to put the e.g. tracing in generic functions, one per arity</p>



<a name="203909120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909120">(Jul 15 2020 at 01:48)</a>:</h4>
<p>so that you don't end up with a lot of code times 600, just one function call</p>



<a name="203909137"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909137" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909137">(Jul 15 2020 at 01:49)</a>:</h4>
<p>i had thought to do that but there's different formatting used per arg depending on the arg type, which i'd hate to lose. The tracing is rarely used so if that's a little slower it's probably okay, but when you do turn it on then it should probably be as helpful as possible</p>



<a name="203909140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909140">(Jul 15 2020 at 01:49)</a>:</h4>
<p>hmm fair</p>



<a name="203909144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909144">(Jul 15 2020 at 01:49)</a>:</h4>
<p>which is also why <code>report_error_as_necessary_from</code> is a single function, because it just says if there's an error or not</p>



<a name="203909193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909193">(Jul 15 2020 at 01:50)</a>:</h4>
<p>there's some stuff like when you explicitly specify the type parameter of <code>_t</code>, you could try to shorten that and rely on inference</p>



<a name="203909216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909216">(Jul 15 2020 at 01:50)</a>:</h4>
<p>like when converting the <code>*mut c_void</code> to the correct system fn type?</p>



<a name="203909221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909221">(Jul 15 2020 at 01:50)</a>:</h4>
<p>is <code>_t</code> transmute?</p>



<a name="203909222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909222">(Jul 15 2020 at 01:50)</a>:</h4>
<p>yes</p>



<a name="203909228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909228">(Jul 15 2020 at 01:51)</a>:</h4>
<p>well that explains my confusion lol</p>



<a name="203909242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909242">(Jul 15 2020 at 01:51)</a>:</h4>
<p>yeah i should take that out, we were having fun on the discord with making things terser to save space on the output</p>



<a name="203909247"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909247" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909247">(Jul 15 2020 at 01:52)</a>:</h4>
<p>but transmute at least should probably stay as itself</p>



<a name="203909294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909294">(Jul 15 2020 at 01:52)</a>:</h4>
<p>presumably you can remove the argument types</p>



<a name="203909296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909296">(Jul 15 2020 at 01:52)</a>:</h4>
<p>and make it e.g. <code>extern "system" fn(_, _)</code></p>



<a name="203909301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909301">(Jul 15 2020 at 01:52)</a>:</h4>
<p>I wonder if that saves any time</p>



<a name="203909303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909303">(Jul 15 2020 at 01:52)</a>:</h4>
<p>that sounds <em>dangerous</em></p>



<a name="203909312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909312">(Jul 15 2020 at 01:53)</a>:</h4>
<p>I mean you're calling it on the next line :P</p>



<a name="203909322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909322">(Jul 15 2020 at 01:53)</a>:</h4>
<p>uhhh, well, okay so it seems to infer the right type i guess</p>



<a name="203909372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909372">(Jul 15 2020 at 01:54)</a>:</h4>
<p>anyway I think you can combine the <code>.load(RELAX)</code>, the <code>transmute</code>, and the entire <code>match</code> (with the call/panic), into one generic function per arity</p>



<a name="203909384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909384">(Jul 15 2020 at 01:54)</a>:</h4>
<p>maybe that helps</p>



<a name="203909394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909394">(Jul 15 2020 at 01:55)</a>:</h4>
<p>hmm, what would that look like while also keeping the transmute coorect?</p>



<a name="203909403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909403">(Jul 15 2020 at 01:55)</a>:</h4>
<p>you rely on the fact that it's per-arity. so e.g. arity 4 would have 4 input types and 1 output type, as type parameters</p>



<a name="203909412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909412">(Jul 15 2020 at 01:55)</a>:</h4>
<p>which you could specify in the same way you do for the transmute today</p>



<a name="203909461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909461">(Jul 15 2020 at 01:56)</a>:</h4>
<p>e.g. instead of <code>extern "system" fn(GLsync, GLbitfield, GLuint64)</code>, you'd give <code>GLsync, GLbitfield, GLuint64, ()</code> as parameters</p>



<a name="203909479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909479">(Jul 15 2020 at 01:57)</a>:</h4>
<p>although at this point I'm starting to wonder why it takes so long in typeck</p>



<a name="203909484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909484">(Jul 15 2020 at 01:57)</a>:</h4>
<p>none of this seems egregious</p>



<a name="203909533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909533">(Jul 15 2020 at 01:58)</a>:</h4>
<p>On monomorphization: its a "cost" when you do have generics and then start instantiating a ton of stuff through a chain of various generics.</p>



<a name="203909540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909540">(Jul 15 2020 at 01:58)</a>:</h4>
<p>right, but that's reflected in the number of total instances</p>



<a name="203909547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909547">(Jul 15 2020 at 01:58)</a>:</h4>
<p>but overall if your eventual code will end up with same number of instances in the end, then monomorphization is actually the best way to save on costs elsewhere in the pipeline.</p>



<a name="203909548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909548">(Jul 15 2020 at 01:58)</a>:</h4>
<p>when accounting for that, it doesn't look nearly as bad</p>



<a name="203909553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909553">(Jul 15 2020 at 01:58)</a>:</h4>
<p>(for now, until we get generic LLVM ^^)</p>



<a name="203909573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909573">(Jul 15 2020 at 01:59)</a>:</h4>
<p><em>in today's installment of "two-word terms to get eddyb hyperventilating"...</em></p>



<a name="203909660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909660">(Jul 15 2020 at 02:00)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> oh, a fun idea: have you considered using your <code>struct</code> code for the static stuff, and just make a <code>static</code> that holds one of those <code>struct</code>s?</p>



<a name="203909670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909670">(Jul 15 2020 at 02:01)</a>:</h4>
<p>a <code>static GL_FNS: GlFns = ...;</code></p>



<a name="203909687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909687">(Jul 15 2020 at 02:01)</a>:</h4>
<p>and call methods on that instead of duplicating the code (I missed that it's what you meant earlier by "two")</p>



<a name="203909701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909701">(Jul 15 2020 at 02:02)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="k">fn</span> <span class="nf">call_atomic_ptr_2arg</span><span class="o">&lt;</span><span class="n">Ret</span><span class="p">,</span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="w"> </span><span class="n">B</span><span class="o">&gt;</span><span class="p">(</span><span class="n">ptr</span>: <span class="kp">&amp;</span><span class="nc">AtomicPtr</span><span class="p">,</span><span class="w"> </span><span class="n">a</span>: <span class="nc">A</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="nc">B</span><span class="p">,</span><span class="w"> </span><span class="n">name</span>: <span class="kp">&amp;</span><span class="kt">str</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Ret</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="c1">// we trace and check errors in whatever fn calls to this</span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">p</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ptr</span><span class="p">.</span><span class="n">load</span><span class="p">(</span><span class="n">RELAX</span><span class="p">);</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">out</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">match</span><span class="w"> </span><span class="n">transmite</span>::<span class="o">&lt;</span><span class="n">_</span><span class="p">,</span><span class="w"> </span><span class="n">O</span><span class="o">&lt;</span><span class="k">extern</span><span class="w"> </span><span class="s">&quot;system&quot;</span><span class="w"> </span><span class="k">fn</span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">B</span><span class="p">)</span>-&gt;<span class="nc">Ret</span><span class="o">&gt;&gt;</span><span class="p">(</span><span class="n">p</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="nb">Some</span><span class="p">(</span><span class="n">fn_p</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">fn_p</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="w"> </span><span class="n">b</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="nb">None</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">go_panic_because_fn_not_loaded</span><span class="p">(</span><span class="n">name</span><span class="p">),</span><span class="w"></span>
<span class="w">  </span><span class="p">};</span><span class="w"></span>
<span class="w">  </span><span class="n">out</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203909744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909744">(Jul 15 2020 at 02:02)</a>:</h4>
<p>so like this?</p>



<a name="203909759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909759">(Jul 15 2020 at 02:02)</a>:</h4>
<p>yeah, probably needs to be <code>unsafe</code> because the atomic ptr is unconstrained but otherwise seems fine</p>



<a name="203909769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909769">(Jul 15 2020 at 02:03)</a>:</h4>
<p>oh, right, yeah and it's transmuting and stuff</p>



<a name="203909782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909782">(Jul 15 2020 at 02:03)</a>:</h4>
<p>(the number of accounted-for bodies is 600*7, 3+3 which are duplicates, plus the static. I wonder if the <code>trace!</code> introduces any bodies)</p>



<a name="203909838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909838">(Jul 15 2020 at 02:04)</a>:</h4>
<p>oh and there's 1369 constants. so okay I think we mostly found all the things being type-checked (and we can kinda ignore the consts, they're really simple)</p>



<a name="203909988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203909988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203909988">(Jul 15 2020 at 02:08)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> btw, if you run <code>crox</code>, how big is the resulting <code>chrome_profile.json</code>?</p>



<a name="203910000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910000">(Jul 15 2020 at 02:08)</a>:</h4>
<p>sometimes we can see anomalies in it</p>



<a name="203910007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910007">(Jul 15 2020 at 02:08)</a>:</h4>
<p>27.4MB</p>



<a name="203910020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910020">(Jul 15 2020 at 02:09)</a>:</h4>
<p>that's a bit big to send :( maybe if you compress it first?</p>



<a name="203910035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910035">(Jul 15 2020 at 02:09)</a>:</h4>
<p>1.2mb when zipped</p>



<a name="203910038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910038">(Jul 15 2020 at 02:09)</a>:</h4>
<p><a href="/user_uploads/4715/GBIU9hTkN4Cq99dm9gL0WPpH/chrome_profiler.zip">chrome_profiler.zip</a></p>



<a name="203910103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910103">(Jul 15 2020 at 02:10)</a>:</h4>
<p>thanks!</p>



<a name="203910206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910206">(Jul 15 2020 at 02:13)</a>:</h4>
<p>heh I can see a pattern where one <code>typeck_tables_of</code> every 5 or so takes ~1.5ms (while the rest are smaller)</p>



<a name="203910288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910288">(Jul 15 2020 at 02:14)</a>:</h4>
<p>even at 1ms, 2*600 would be 1.2s, spent type-checking just big functions/methods (the unsuffixed ones)</p>



<a name="203910317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910317">(Jul 15 2020 at 02:15)</a>:</h4>
<p>there's two big <code>typeck_tables_of</code>, I assume those are, like, the one that loads all of the functions, and some other one that's similarly big</p>



<a name="203910334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910334">(Jul 15 2020 at 02:15)</a>:</h4>
<p>one for global loader and one for struct loader?</p>



<a name="203910339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910339">(Jul 15 2020 at 02:15)</a>:</h4>
<p>oh I guess so</p>



<a name="203910392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910392">(Jul 15 2020 at 02:16)</a>:</h4>
<p>overall this looks pretty boring. the most important thing I'm gathering is that the helper functions don't hurt much</p>



<a name="203910472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910472">(Jul 15 2020 at 02:18)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> anyway if you want to play around, and happen to have chrom{e,ium} around, should be easy to load it up: <a href="/user_uploads/4715/6Ugk0Q17IbwSzqC_0mzW00gy/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/6Ugk0Q17IbwSzqC_0mzW00gy/image.png" title="image.png"><img src="/user_uploads/4715/6Ugk0Q17IbwSzqC_0mzW00gy/image.png"></a></div>



<a name="203910482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910482">(Jul 15 2020 at 02:18)</a>:</h4>
<p>i'm still back on making it generate the arity functions! :ferrisSweat:</p>



<a name="203910484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910484">(Jul 15 2020 at 02:18)</a>:</h4>
<p>heh</p>



<a name="203910498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910498">(Jul 15 2020 at 02:19)</a>:</h4>
<p>I hope you have a copy of the old code (in git or something)</p>



<a name="203910531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910531">(Jul 15 2020 at 02:19)</a>:</h4>
<p>oh and if you want to see what actual function it's working on and whatnot, you need to add <code>-Zself-profile-events=default,query-keys</code></p>



<a name="203910539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910539">(Jul 15 2020 at 02:19)</a>:</h4>
<p>should've mentioned this earlier (but presumably it makes the <code>chrome_profile.json</code> much bigger)</p>



<a name="203910540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910540">(Jul 15 2020 at 02:19)</a>:</h4>
<p>you mean before and after the arity change?</p>



<a name="203910552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910552">(Jul 15 2020 at 02:20)</a>:</h4>
<p>whichever you want to look at more</p>



<a name="203910981"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203910981" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203910981">(Jul 15 2020 at 02:29)</a>:</h4>
<p>Alright here we go, <a href="https://gist.github.com/rust-play/97d5bec735eb12af3bda78efec55d2e4">https://gist.github.com/rust-play/97d5bec735eb12af3bda78efec55d2e4</a></p>



<a name="203911065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203911065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203911065">(Jul 15 2020 at 02:31)</a>:</h4>
<p>i guess we'll give it the inline(always) bump too, though i'm told that a small private generic function will effectively always be inlined anyway</p>



<a name="203911126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203911126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203911126">(Jul 15 2020 at 02:32)</a>:</h4>
<p>beautiful,,,</p>



<a name="203911196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203911196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203911196">(Jul 15 2020 at 02:34)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> btw if you want a more advanced version of that <code>Deref</code> trick, <span class="user-mention" data-user-id="119235">@David Tolnay</span> linked me <a href="https://docs.rs/hackfn/">https://docs.rs/hackfn/</a> on twitter</p>



<a name="203911220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203911220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203911220">(Jul 15 2020 at 02:35)</a>:</h4>
<p>oof</p>



<a name="203911223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203911223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203911223">(Jul 15 2020 at 02:35)</a>:</h4>
<p>(you would only need to use it once per arity, not once per each function - although none of that makes any sense for the struct loader, so you can ignore it)</p>



<a name="203911227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203911227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203911227">(Jul 15 2020 at 02:35)</a>:</h4>
<p>also don't look at the implementation, you'll regret it :P</p>



<a name="203911323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203911323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203911323">(Jul 15 2020 at 02:37)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="w">  </span><span class="sd">/// [glEnablei](http://docs.gl/gl4/glEnablei)(target, index)</span>
<span class="w">  </span><span class="sd">/// * `target` group: EnableCap</span>
<span class="w">  </span><span class="cp">#[cfg_attr(feature = </span><span class="s">&quot;inline&quot;</span><span class="cp">, inline)]</span><span class="w"></span>
<span class="w">  </span><span class="cp">#[cfg_attr(feature = </span><span class="s">&quot;inline_always&quot;</span><span class="cp">, inline(always))]</span><span class="w"></span>
<span class="w">  </span><span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">glEnablei</span><span class="p">(</span><span class="n">target</span>: <span class="nc">GLenum</span><span class="p">,</span><span class="w"> </span><span class="n">index</span>: <span class="nc">GLuint</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[cfg(all(debug_assertions, feature = </span><span class="s">&quot;debug_trace_calls&quot;</span><span class="cp">))]</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">trace</span><span class="o">!</span><span class="p">(</span><span class="s">&quot;calling glEnablei({:#X}, {:?});&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">target</span><span class="p">,</span><span class="w"> </span><span class="n">index</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">out</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">call_atomic_ptr_2arg</span><span class="p">(</span><span class="n">glEnablei</span><span class="p">,</span><span class="w"> </span><span class="n">glEnablei_p</span><span class="p">,</span><span class="w"> </span><span class="n">target</span><span class="p">,</span><span class="w"> </span><span class="n">index</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="cp">#[cfg(all(debug_assertions, feature = </span><span class="s">&quot;debug_automatic_glGetError&quot;</span><span class="cp">))]</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="n">report_error_as_necessary_from</span><span class="p">(</span><span class="s">&quot;glEnablei&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">glGetError</span><span class="p">());</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="n">out</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="203911332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203911332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203911332">(Jul 15 2020 at 02:37)</a>:</h4>
<p>oops, forgot some double quotes</p>



<a name="203912380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203912380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203912380">(Jul 15 2020 at 03:02)</a>:</h4>
<p><a href="https://gist.github.com/rust-play/363cc0e57920da3216c648babc77afeb">https://gist.github.com/rust-play/363cc0e57920da3216c648babc77afeb</a> with the generic arity system in place</p>



<a name="203912543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203912543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203912543">(Jul 15 2020 at 03:06)</a>:</h4>
<p><a href="/user_uploads/4715/S0Mi23W5a3-62nXnqkBWcOW3/chrome_profiler.zip">chrome_profiler.zip</a></p>



<a name="203912686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203912686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203912686">(Jul 15 2020 at 03:10)</a>:</h4>
<p>Okay so we actually took 0.4MB of source size off with these changes</p>



<a name="203920077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203920077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203920077">(Jul 15 2020 at 06:17)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> How long is your build (not check) time, and what does your normal workflow look like?</p>



<a name="203920576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203920576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203920576">(Jul 15 2020 at 06:29)</a>:</h4>
<p>By the way, is there a guide to reading the crox output? E.g. I have a 15 LOC crate that takes 24 seconds to compile without debug info (because it's using generics from dependencies), but I'm not sure how to interpret the output.</p>



<a name="203920649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203920649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203920649">(Jul 15 2020 at 06:31)</a>:</h4>
<p>It looks like LLVM thin-LTO takes too long, but that's not really actionable</p>



<a name="203920795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203920795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203920795">(Jul 15 2020 at 06:34)</a>:</h4>
<p><a href="/user_uploads/4715/7CUkLX-RlNTOcL98xnR0zUS5/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/7CUkLX-RlNTOcL98xnR0zUS5/image.png" title="image.png"><img src="/user_uploads/4715/7CUkLX-RlNTOcL98xnR0zUS5/image.png"></a></div>



<a name="203924889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203924889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203924889">(Jul 15 2020 at 07:45)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> if <code>cargo check</code> times are not what you're worried about, I doubt <code>-Z self-profile</code> is that useful</p>



<a name="203924908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203924908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203924908">(Jul 15 2020 at 07:45)</a>:</h4>
<p>Nope, <code>cargo build --release</code>. I guess you're right, it doesn't seem too useful.</p>



<a name="203925098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925098">(Jul 15 2020 at 07:47)</a>:</h4>
<p>Shouldn't there be more parallelism in ThinLTO?</p>



<a name="203925169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925169">(Jul 15 2020 at 07:48)</a>:</h4>
<p>the LLVM parallelism is limited by two things: CGU partitioning, and single-threaded MIR -&gt; LLVM IR feeding it</p>



<a name="203925179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925179">(Jul 15 2020 at 07:48)</a>:</h4>
<p>the latter is why there's staggering across time</p>



<a name="203925197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925197">(Jul 15 2020 at 07:49)</a>:</h4>
<p>although maybe not, I just can't see enough of that</p>



<a name="203925282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925282">(Jul 15 2020 at 07:50)</a>:</h4>
<p>but I believe that kind of shape with tiny threads indicates some of the CGUs are significantly smaller than others</p>



<a name="203925326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925326">(Jul 15 2020 at 07:51)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> it might be useful to take that screenshot making sure to include only 0 to 12000-13000 (wherever thread 37 starts)</p>



<a name="203925346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925346">(Jul 15 2020 at 07:51)</a>:</h4>
<p>oh I see what you mean about ThinLTO, as it starts after all the CGUs are done</p>



<a name="203925412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925412">(Jul 15 2020 at 07:52)</a>:</h4>
<p>I don't know about ThinLTO internals. cc <span class="user-mention" data-user-id="123586">@nagisa</span> <span class="user-mention" data-user-id="124289">@Hanna Kruppe</span></p>



<a name="203925447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203925447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203925447">(Jul 15 2020 at 07:52)</a>:</h4>
<p>I think it single-threadedly combines the result of having optimized the CGUs in parallel?</p>



<a name="203926278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203926278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203926278">(Jul 15 2020 at 08:03)</a>:</h4>
<p>Thread 37 is <code>codegen_module_perform_lto</code></p>



<a name="203926313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203926313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203926313">(Jul 15 2020 at 08:03)</a>:</h4>
<p>And the first threads are <code>codegen_module_optimize</code></p>



<a name="203926393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203926393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203926393">(Jul 15 2020 at 08:04)</a>:</h4>
<p><a href="/user_uploads/4715/GA1ABrMqj1_P4AmfjiQbR_lJ/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/GA1ABrMqj1_P4AmfjiQbR_lJ/image.png" title="image.png"><img src="/user_uploads/4715/GA1ABrMqj1_P4AmfjiQbR_lJ/image.png"></a></div>



<a name="203926436"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203926436" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203926436">(Jul 15 2020 at 08:05)</a>:</h4>
<p>ah at this zoom level you can see the MIR -&gt; LLVM IR :)</p>



<a name="203926487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203926487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203926487">(Jul 15 2020 at 08:05)</a>:</h4>
<p>I think it's the long purple sections between the green slivers, on thread 2 (we should probably categorize MIR -&gt; LLVM IR, and LLVM optimizations, differently, and therefore use different  colors)</p>



<a name="203926576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203926576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203926576">(Jul 15 2020 at 08:07)</a>:</h4>
<p>Yeah, thread 2 does all kinds of interesting stuff that's mostly fast :)</p>



<a name="203926589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203926589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203926589">(Jul 15 2020 at 08:07)</a>:</h4>
<p><a href="/user_uploads/4715/RSsqsnszoTMIsDachjdmZmEH/image.png">image.png</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/RSsqsnszoTMIsDachjdmZmEH/image.png" title="image.png"><img src="/user_uploads/4715/RSsqsnszoTMIsDachjdmZmEH/image.png"></a></div>



<a name="203926683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203926683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203926683">(Jul 15 2020 at 08:08)</a>:</h4>
<p>This is from rust-analyzer, btw</p>



<a name="203949859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203949859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203949859">(Jul 15 2020 at 12:43)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> Well <code>phosphorus</code> (the bindings generator) is fairly fast (~1.5 to 2 seconds, ish). When we take some generated output and put it into the <code>gl46</code> crate, which is what people will actually be depending on, we the the following sample build times:</p>
<div class="codehilite"><pre><span></span><code>&gt;cargo clean &amp;&amp; cargo build --features=global_loader
    Finished dev [unoptimized + debuginfo] target(s) in 2.55s

&gt;cargo clean &amp;&amp; cargo build --features=struct_loader
    Finished dev [unoptimized + debuginfo] target(s) in 2.51s

&gt;cargo clean &amp;&amp; cargo build --features=global_loader --release
    Finished release [optimized] target(s) in 2.81s

&gt;cargo clean &amp;&amp; cargo build --features=struct_loader --release
    Finished release [optimized] target(s) in 2.89s
</code></pre></div>



<a name="203951161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203951161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203951161">(Jul 15 2020 at 12:56)</a>:</h4>
<p>the <code>lib.rs</code> is 2.24 mb of source</p>
<ul>
<li><code>rustc</code> seems to do what I'd call reasonably well with this much input. Not as fast as maybe a C compiler could do things, but you get a response quickly enough and I'm certainly doing things that I couldn't do in C.</li>
<li><code>rust-analyzer</code> chokes and sputters and sometimes even dies. The checking takes seemingly 10+ seconds to perform, if it returns results at all. Frequently the enter key takes over 5 seconds to actually insert the newline because I guess it can't run the "smart enter" feature while also running the analysis. There's clearly a lot of work to be done before RA is ready for seriously large projects.</li>
</ul>



<a name="203952696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203952696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203952696">(Jul 15 2020 at 13:08)</a>:</h4>
<p>huh, I would've expected RA to do better, maybe they're not indexing something efficiently (like methods by name)</p>



<a name="203952891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203952891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203952891">(Jul 15 2020 at 13:10)</a>:</h4>
<p>please post an example project so we can look into this</p>



<a name="203953084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953084">(Jul 15 2020 at 13:12)</a>:</h4>
<p>Filed <a href="https://github.com/rust-analyzer/rust-analyzer/issues/5392">https://github.com/rust-analyzer/rust-analyzer/issues/5392</a>. Look like pretty much everything is slow. For example some uncached slop in hover:</p>
<div class="codehilite"><pre><span></span><code>  128ms - handle_hover
      127ms - Semantics::analyze2
            0ms - crate_def_map:wait (2 calls)
            0ms - infer:wait (1 calls)
            0ms - module_to_def (1 calls)
          127ms - ???
        0ms - classify_name_ref (1 calls)
        0ms - crate_def_map:wait (7 calls)
</code></pre></div>



<a name="203953126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953126">(Jul 15 2020 at 13:13)</a>:</h4>
<p>there are some cases where Chalk still asks us to enumerate all impls for a trait, I suspect a lot of these problems come from that... maybe we should just stop doing that, at the cost of giving wrong results</p>



<a name="203953260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953260">(Jul 15 2020 at 13:14)</a>:</h4>
<p>ah, maybe not if it's just an abnormally big file</p>



<a name="203953294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953294">(Jul 15 2020 at 13:14)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> do you ever have to iterate through e.g. <code>impl</code> methods, to find one by name?</p>



<a name="203953390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953390">(Jul 15 2020 at 13:15)</a>:</h4>
<p>IIRC <span class="user-mention" data-user-id="118594">@ecstatic-morse</span> optimized the rustc implementation to have a fancy name-keying system, where you can still iterate the children but also find all the ones with a specific name (there can be more than 1 because of type vs value namespace or macro hygiene)</p>



<a name="203953464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953464">(Jul 15 2020 at 13:16)</a>:</h4>
<p>yeah, we don't index methods by name currently</p>



<a name="203953546"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953546" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953546">(Jul 15 2020 at 13:17)</a>:</h4>
<p>no idea if it would help here, but there is an <code>impl</code> with <code>600*3</code> methods, so that could get painful to iterate over (especially if done <code>600*n</code> times, although I didn't check what <code>n</code> is)</p>



<a name="203953601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953601">(Jul 15 2020 at 13:17)</a>:</h4>
<p>hmm I can stress test this pretty easily</p>



<a name="203953885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953885">(Jul 15 2020 at 13:20)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> <a href="https://github.com/Lokathor/gl46">https://github.com/Lokathor/gl46</a> is the repo link</p>



<a name="203953955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953955">(Jul 15 2020 at 13:21)</a>:</h4>
<p><span class="user-mention" data-user-id="129457">@Florian Diebold</span> <span class="user-mention" data-user-id="211727">@Jonas Schievink</span> try this out on RA and compare with <code>rustc</code> <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=f9848e4e13d12d4a6a9f3bc9dde714d3">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=f9848e4e13d12d4a6a9f3bc9dde714d3</a></p>



<a name="203953999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203953999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203953999">(Jul 15 2020 at 13:21)</a>:</h4>
<blockquote>
<p>Finished dev [unoptimized + debuginfo] target(s) in 0.75s</p>
</blockquote>



<a name="203954012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954012">(Jul 15 2020 at 13:21)</a>:</h4>
<p>LLVM LTO can be parallel but broadly its very prone to long tail problem</p>



<a name="203954028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954028">(Jul 15 2020 at 13:21)</a>:</h4>
<p>checking that stress test shouldn't take longer than a second, really</p>



<a name="203954034"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954034" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954034">(Jul 15 2020 at 13:21)</a>:</h4>
<p>don’t think there's much actionable about it sadly T_T</p>



<a name="203954098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954098">(Jul 15 2020 at 13:22)</a>:</h4>
<p>also no traits are involved so hopefully you don't hit Chalk</p>



<a name="203954136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954136">(Jul 15 2020 at 13:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F/near/203953955">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <span class="user-mention silent" data-user-id="211727">Jonas Schievink</span> try this out on RA and compare with <code>rustc</code> <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=f9848e4e13d12d4a6a9f3bc9dde714d3">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=f9848e4e13d12d4a6a9f3bc9dde714d3</a></p>
</blockquote>
<p>It's fast for me</p>



<a name="203954158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954158">(Jul 15 2020 at 13:22)</a>:</h4>
<p>intriguing</p>



<a name="203954189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954189">(Jul 15 2020 at 13:23)</a>:</h4>
<p>maybe it's fields?</p>



<a name="203954242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954242">(Jul 15 2020 at 13:23)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> <span class="user-mention" data-user-id="118594">@ecstatic-morse</span> oh hey I don't think we index fields by name, do we? that might be something to look into, huh</p>



<a name="203954243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954243">(Jul 15 2020 at 13:23)</a>:</h4>
<p>could be the task of indexing 3000 consts?</p>



<a name="203954273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954273">(Jul 15 2020 at 13:23)</a>:</h4>
<p>there's nothing in them though, other than literals</p>



<a name="203954506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954506">(Jul 15 2020 at 13:25)</a>:</h4>
<p>you shouldn't go past 1s with O(n), it's likely quadratic behavior (possibly even for <code>rustc</code> still) that amplifies "hundreds" into "close to a million"</p>



<a name="203954733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954733">(Jul 15 2020 at 13:27)</a>:</h4>
<p>this is slower but not that slow <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=2c90d8c8b16bd07c175ff496893b5968">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=2c90d8c8b16bd07c175ff496893b5968</a></p>



<a name="203954753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954753">(Jul 15 2020 at 13:27)</a>:</h4>
<p>feel free to also try that in RA</p>



<a name="203954875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954875">(Jul 15 2020 at 13:28)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> is it faster if you disable inlay hints? (<code>rust-analyzer.inlayHints.enable</code>)</p>



<a name="203954959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954959">(Jul 15 2020 at 13:29)</a>:</h4>
<p>well idk if I can trust playground numbers. this should be even slower <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=199b6cfb28cdec72b671e04d9d4208aa">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=199b6cfb28cdec72b671e04d9d4208aa</a></p>



<a name="203954972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954972">(Jul 15 2020 at 13:29)</a>:</h4>
<p>how is the performance of <code>rust-analyzer analysis-stats .</code> in the repository?</p>



<a name="203954979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954979">(Jul 15 2020 at 13:29)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> can you try my last two links?</p>



<a name="203954996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203954996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203954996">(Jul 15 2020 at 13:29)</a>:</h4>
<p>/me should get around to installing RA</p>



<a name="203955068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203955068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203955068">(Jul 15 2020 at 13:30)</a>:</h4>
<p><span class="user-mention silent" data-user-id="129457">Florian Diebold</span> <a href="#narrow/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F/near/203954972">said</a>:</p>
<blockquote>
<p>how is the performance of <code>rust-analyzer analysis-stats .</code> in the repository?</p>
</blockquote>
<p>2.7s item collection, 790ms inference</p>



<a name="203955282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203955282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203955282">(Jul 15 2020 at 13:32)</a>:</h4>
<p>method resolution isn't optimized at all in RA and also has to be able to enumerate all methods for completion, so I wouldn't be surprised if it's slow, anyway</p>



<a name="203955328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203955328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203955328">(Jul 15 2020 at 13:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F/near/203954979">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="203546">Laurențiu Nicola</span> can you try my last two links?</p>
</blockquote>
<p>The one with fields is a bit slower, I think. It starts complaining about LSP requests taking too long, but it's not so bad overall</p>



<a name="203955569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203955569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203955569">(Jul 15 2020 at 13:35)</a>:</h4>
<p>Maybe it's just slow on large files</p>



<a name="203955586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203955586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203955586">(Jul 15 2020 at 13:35)</a>:</h4>
<p><span class="user-mention" data-user-id="203546">@Laurențiu Nicola</span> sadly i have left the house for work,  but i could check that later today</p>



<a name="203955638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203955638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203955638">(Jul 15 2020 at 13:35)</a>:</h4>
<p>(and you can also disable the smart Enter thingy, at least on that project)</p>



<a name="203955704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203955704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203955704">(Jul 15 2020 at 13:36)</a>:</h4>
<p>(but I guess you don't really edit that file)</p>



<a name="203955800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203955800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203955800">(Jul 15 2020 at 13:37)</a>:</h4>
<p>well it hasn't been an issue on any other project yet.</p>
<p>I did try to do some editing in that file during the fix ups yesterday and i had to switch to editing in a notepad instance and then pasting a completed function into the file, because editing in vs code directly was too unresponsive</p>



<a name="203958447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203958447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203958447">(Jul 15 2020 at 13:58)</a>:</h4>
<p>Is RA also slow on downstream creates or only when directly editing the generated one?</p>



<a name="203966493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203966493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203966493">(Jul 15 2020 at 15:00)</a>:</h4>
<p>if you check out this fork of glow, <a href="https://github.com/Lokathor/glow">https://github.com/Lokathor/glow</a>, and try the <code>gl46</code> branch you can have an example of using the large crate as a dependency of a smaller crate.</p>
<p>The patch in that branch took a very short amount of time to write, so I wouldn't say I have a full sense of it, but the editing did seem to at least never block on the Enter key being pressed. I don't recall if the error info was consistently very responsive or not, I just used <code>cargo-watch</code> for that particular bit of work.</p>



<a name="203975354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/203975354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joe Clay <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#203975354">(Jul 15 2020 at 16:02)</a>:</h4>
<p>I played around with switching my crate to use Lokathor's fork/branch of <code>glow</code> and it didn't seem to make RA slow down, so I don't think downstream crates are affected</p>



<a name="215049309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049309">(Oct 30 2020 at 01:57)</a>:</h4>
<p>So I have the same question for <a href="http://docs.rs">docs.rs</a></p>



<a name="215049315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049315">(Oct 30 2020 at 01:57)</a>:</h4>
<p>we have 19 second incremental compile times <span aria-label="sob" class="emoji emoji-1f62d" role="img" title="sob">:sob:</span></p>



<a name="215049372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049372">(Oct 30 2020 at 01:58)</a>:</h4>
<p>here are the top 10 things from <code>-Z self-profile</code>: </p>
<div class="codehilite"><pre><span></span><code>+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| Item                                        | Self time | % of total time | Time     | Item count | Cache hits | Blocked time | Incremental load time |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_module_codegen_emit_obj                | 19.08s    | 44.091          | 19.08s   | 256        | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_passes                                 | 8.35s     | 19.293          | 8.35s    | 1          | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| codegen_module                              | 7.33s     | 16.945          | 8.32s    | 256        | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| typeck                                      | 900.86ms  | 2.082           | 1.13s    | 1294       | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| mir_borrowck                                | 659.97ms  | 1.525           | 1.46s    | 1294       | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_module_codegen                         | 609.68ms  | 1.409           | 19.69s   | 256        | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| evaluate_obligation                         | 424.14ms  | 0.980           | 533.60ms | 17265      | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_module_optimize_module_passes          | 372.71ms  | 0.861           | 372.71ms | 256        | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| expand_crate                                | 329.54ms  | 0.762           | 400.48ms | 1          | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| mir_built                                   | 283.94ms  | 0.656           | 373.03ms | 1294       | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
</code></pre></div>



<a name="215049402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049402">(Oct 30 2020 at 01:59)</a>:</h4>
<p>is there a way to say 'more debug than debug'? I don't care at <em>all</em> about optimizations for debug mode</p>



<a name="215049431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049431">(Oct 30 2020 at 01:59)</a>:</h4>
<p>and it looks like they're sucking up a good 10 seconds of the build</p>



<a name="215049618"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049618" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049618">(Oct 30 2020 at 02:02)</a>:</h4>
<p>here's <code>-Z print-mono-items</code> if it helps: <a href="https://gist.github.com/jyn514/909444d975dfd3b9ae5b5c5f4fdc36c0">https://gist.github.com/jyn514/909444d975dfd3b9ae5b5c5f4fdc36c0</a></p>



<a name="215049630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Tyson Nottingham <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049630">(Oct 30 2020 at 02:03)</a>:</h4>
<p>Possibly <code>-C no-prepopulate-passes</code>?</p>



<a name="215049733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049733">(Oct 30 2020 at 02:05)</a>:</h4>
<p>that already brought it down to 15 seconds :)</p>



<a name="215049740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049740">(Oct 30 2020 at 02:05)</a>:</h4>
<div class="codehilite"><pre><span></span><code>+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| Item                                        | Self time | % of total time | Time     | Item count | Cache hits | Blocked time | Incremental load time |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_module_codegen_emit_obj                | 18.06s    | 44.331          | 18.06s   | 256        | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_passes                                 | 7.97s     | 19.549          | 7.97s    | 1          | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| codegen_module                              | 6.90s     | 16.935          | 7.80s    | 256        | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| typeck                                      | 904.32ms  | 2.219           | 1.14s    | 1294       | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
| LLVM_module_codegen                         | 621.63ms  | 1.526           | 18.69s   | 256        | 0          | 0.00ns       | 0.00ns                |
+---------------------------------------------+-----------+-----------------+----------+------------+------------+--------------+-----------------------+
</code></pre></div>



<a name="215049804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049804">(Oct 30 2020 at 02:06)</a>:</h4>
<p>8 seconds on llvm is still a lot :/</p>



<a name="215049810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049810">(Oct 30 2020 at 02:07)</a>:</h4>
<p>is there a way to see if there's something being monomorphized over and over?</p>



<a name="215049834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049834">(Oct 30 2020 at 02:07)</a>:</h4>
<p>cranelift?</p>



<a name="215049842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215049842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215049842">(Oct 30 2020 at 02:07)</a>:</h4>
<p>lol well yes</p>



<a name="215050018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215050018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215050018">(Oct 30 2020 at 02:10)</a>:</h4>
<p>and getting rid of some not-often used code brought it down another two seconds, let me feature-gate that</p>



<a name="215050508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215050508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215050508">(Oct 30 2020 at 02:21)</a>:</h4>
<p>let me try cargo-llvm lines too</p>



<a name="215050683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215050683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215050683">(Oct 30 2020 at 02:25)</a>:</h4>
<p>wow, that is ... significantly more than expected</p>
<div class="codehilite"><pre><span></span><code>   Compiling docs-rs v0.6.0 (/home/joshua/src/rust/docs.rs)
    Finished dev [unoptimized + debuginfo] target(s) in 34.50s
  Lines          Copies        Function name
  -----          ------        -------------
  621273 (100%)  15169 (100%)  (TOTAL)
   22828 (3.7%)   1224 (8.1%)  core::ptr::drop_in_place
   10599 (1.7%)     17 (0.1%)  &lt;&amp;mut serde_json::de::Deserializer&lt;R&gt; as serde::de::Deserializer&gt;::deserialize_struct
    7930 (1.3%)     26 (0.2%)  &lt;serde_json::de::SeqAccess&lt;R&gt; as serde::de::SeqAccess&gt;::next_element_seed
    6370 (1.0%)     35 (0.2%)  alloc::raw_vec::RawVec&lt;T,A&gt;::grow_amortized
    5399 (0.9%)     89 (0.6%)  core::result::Result&lt;T,E&gt;::map_err
    5214 (0.8%)    105 (0.7%)  core::option::Option&lt;T&gt;::map
    4845 (0.8%)     17 (0.1%)  &lt;serde_json::de::MapAccess&lt;R&gt; as serde::de::MapAccess&gt;::next_key_seed
    4680 (0.8%)     13 (0.1%)  docs_rs::web::page::web_page::WebPage::into_response
</code></pre></div>



<a name="215050731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215050731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215050731">(Oct 30 2020 at 02:26)</a>:</h4>
<p>full log: <a href="https://gist.github.com/jyn514/3a99fca8e1d3a8048d6bba409b76b381">https://gist.github.com/jyn514/3a99fca8e1d3a8048d6bba409b76b381</a></p>



<a name="215051100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215051100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215051100">(Oct 30 2020 at 02:34)</a>:</h4>
<p>opened <a href="https://github.com/serde-rs/json/issues/727">https://github.com/serde-rs/json/issues/727</a></p>



<a name="215063032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215063032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215063032">(Oct 30 2020 at 07:30)</a>:</h4>
<p>Also turning off debug info, if relevant</p>



<a name="215065109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215065109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215065109">(Oct 30 2020 at 08:10)</a>:</h4>
<p>I'd like to have debug info if possible :/ maybe I can turn it down to <code>debuginfo = 1</code></p>



<a name="215065154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215065154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215065154">(Oct 30 2020 at 08:11)</a>:</h4>
<p>That helps. Also using <code>lld</code> instead of <code>ld</code></p>



<a name="215093039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093039">(Oct 30 2020 at 13:20)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F/near/215049402">said</a>:</p>
<blockquote>
<p>is there a way to say 'more debug than debug'? I don't care at <em>all</em> about optimizations for debug mode</p>
</blockquote>
<p>FYI <code>LLVM_passes</code> includes both optimization passes as well as passes required to lower the IR to machine code. AFAIK, <code>debug</code> mode doesn't run any LLVM optimization passes.</p>



<a name="215093055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093055">(Oct 30 2020 at 13:20)</a>:</h4>
<p>These are all general rust things though - is there any way to figure out why <a href="http://docs.rs">docs.rs</a> takes so much <em>more</em> time than other projects?</p>



<a name="215093100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093100">(Oct 30 2020 at 13:21)</a>:</h4>
<blockquote>
<p>AFAIK debug mode doesn't run any LLVM optimization passes</p>
</blockquote>
<p>Hmm, ok. Maybe my benchmark was just off?</p>



<a name="215093246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093246">(Oct 30 2020 at 13:22)</a>:</h4>
<p>Pass <code>-Z no-parallel-llvm -Z llvm-time-trace</code></p>



<a name="215093273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093273">(Oct 30 2020 at 13:22)</a>:</h4>
<p>Then load <code>llvm_timings.json</code> up in chrome or speedscope</p>



<a name="215093359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093359">(Oct 30 2020 at 13:23)</a>:</h4>
<p>That does the same thing as clang's <code>-ftime-trace</code> <a href="https://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/">https://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/</a></p>



<a name="215093506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093506">(Oct 30 2020 at 13:24)</a>:</h4>
<p>There's a lot of serde stuff in the llvm-lines output. Serde is surprisingly expensive in terms of downstream compile times. In rust-analyzer we've moved all the serde types and (de)serialization into a dedicated crate, maybe you can do something similar here?</p>



<a name="215093822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093822">(Oct 30 2020 at 13:28)</a>:</h4>
<blockquote>
<p>In rust-analyzer we've moved all the serde types and (de)serialization into a dedicated crate</p>
</blockquote>
<p>We did? <span aria-label="confused" class="emoji emoji-1f615" role="img" title="confused">:confused:</span>. There are some <code>derive</code>s in <code>rust-analyzer</code>, <code>ide</code> and <code>project_model</code> (and also the proc macro stuff)</p>



<a name="215093965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093965">(Oct 30 2020 at 13:29)</a>:</h4>
<p>Hmm, or maybe not? I think <span class="user-mention" data-user-id="133169">@matklad</span> explained this to me once?</p>



<a name="215093990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215093990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215093990">(Oct 30 2020 at 13:29)</a>:</h4>
<p>I don't think <em>everything</em> got moved to another crate though</p>



<a name="215094092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215094092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215094092">(Oct 30 2020 at 13:30)</a>:</h4>
<p>Yeah, I guess so. There's also that LSP crate (<code>lsp-types</code>) which probably has most of the types that use <code>serde</code></p>



<a name="215095528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215095528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215095528">(Oct 30 2020 at 13:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="211727">Jonas Schievink</span> <a href="#narrow/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F/near/215093506">said</a>:</p>
<blockquote>
<p>There's a lot of serde stuff in the llvm-lines output. Serde is surprisingly expensive in terms of downstream compile times. In rust-analyzer we've moved all the serde types and (de)serialization into a dedicated crate, maybe you can do something similar here?</p>
</blockquote>
<p>I'm hoping I can get rid of serde altogether: <a href="https://github.com/rust-lang/docs.rs/pull/1143">https://github.com/rust-lang/docs.rs/pull/1143</a></p>



<a name="215095542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215095542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215095542">(Oct 30 2020 at 13:43)</a>:</h4>
<p>at least for most of the codebase</p>



<a name="215103874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215103874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215103874">(Oct 30 2020 at 14:46)</a>:</h4>
<p>No, we didn't move serde types anywhere. They mostly were in the <code>lsp_types</code> crate from the start, and they do take absolutely unforgivable amount of time to compile.</p>



<a name="215103925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215103925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215103925">(Oct 30 2020 at 14:47)</a>:</h4>
<p>Okay, then I'm just confused :D</p>



<a name="215103977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215103977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215103977">(Oct 30 2020 at 14:47)</a>:</h4>
<p>I guess someone should red-eye a dynamically dispatched version of serde</p>



<a name="215104110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215104110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215104110">(Oct 30 2020 at 14:48)</a>:</h4>
<p>there's a bunch of miniserdes out there, but they all feel like pocs mostly. I wonder what the optimized for compile-times serde would look like...</p>



<a name="215104229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215104229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215104229">(Oct 30 2020 at 14:49)</a>:</h4>
<p>what's pocs?</p>



<a name="215104281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215104281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215104281">(Oct 30 2020 at 14:50)</a>:</h4>
<p>proofs of concept</p>



<a name="215104292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215104292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215104292">(Oct 30 2020 at 14:50)</a>:</h4>
<p>There's also <code>erased-serde</code>, but that's still <code>serde</code> underneath</p>



<a name="215104825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215104825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215104825">(Oct 30 2020 at 14:54)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span>  so these are pocs aimed at reducing compile times?</p>



<a name="215107606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215107606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215107606">(Oct 30 2020 at 15:11)</a>:</h4>
<p>Yup: <a href="https://github.com/dtolnay/miniserde">https://github.com/dtolnay/miniserde</a>. And I think there was micro/nano/femto/pico serde or some such as well?</p>



<a name="215107788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215107788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215107788">(Oct 30 2020 at 15:12)</a>:</h4>
<p>There are three factors here:</p>
<ol>
<li>the time it takes to build <code>serde</code> (mostly <code>syn</code> when using <code>#[derive]</code>)</li>
<li>the time it takes for the serde proc macro to run</li>
<li>the time it takes to compile the serde proc macro output</li>
</ol>
<p>For example, proc macros are now built in debug mode decreasing 1, but increasing 2</p>



<a name="215107844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215107844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215107844">(Oct 30 2020 at 15:12)</a>:</h4>
<p>our issues are with 3.</p>



<a name="215107868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215107868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215107868">(Oct 30 2020 at 15:12)</a>:</h4>
<p>fully 5% of all of <a href="http://docs.rs">docs.rs</a> llvm-lines are from 3</p>



<a name="215107934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215107934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215107934">(Oct 30 2020 at 15:13)</a>:</h4>
<p>syn itself taking long to build is annoying but doesn't affect incremental a ton</p>



<a name="215108049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108049">(Oct 30 2020 at 15:14)</a>:</h4>
<p>with a trade-off of feature support</p>



<a name="215108087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108087">(Oct 30 2020 at 15:14)</a>:</h4>
<p>^(potential 4'th factor)</p>



<a name="215108153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108153">(Oct 30 2020 at 15:14)</a>:</h4>
<p>we don't need many features really</p>



<a name="215108168"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108168" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108168">(Oct 30 2020 at 15:15)</a>:</h4>
<p>I might check out miniserde</p>



<a name="215108256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108256">(Oct 30 2020 at 15:15)</a>:</h4>
<p>The <code>serde</code> deserialization code is quite flexible in what it accepts IIRC. I guess a hand-written version might compile faster.</p>



<a name="215108272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108272">(Oct 30 2020 at 15:16)</a>:</h4>
<p>It's also doing a lot of validations for e.g. repeated keys</p>



<a name="215108285"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108285" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108285">(Oct 30 2020 at 15:16)</a>:</h4>
<p>my crate compiles faster because it is less seems obvious</p>



<a name="215108394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108394">(Oct 30 2020 at 15:17)</a>:</h4>
<p>not to interject ^.^</p>



<a name="215108414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108414">(Oct 30 2020 at 15:17)</a>:</h4>
<p>For 1, 2 you can also run <code>cargo expand</code> and check in the generated code</p>



<a name="215108472"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108472" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108472">(Oct 30 2020 at 15:17)</a>:</h4>
<p>well, also switching to cargo_metadata is just a good idea</p>



<a name="215108502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108502">(Oct 30 2020 at 15:17)</a>:</h4>
<p>I discovered unwrap()s I didn't know I had because serde panics if the input is invalid</p>



<a name="215108560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108560">(Oct 30 2020 at 15:18)</a>:</h4>
<p>(or maybe returns an error?)</p>



<a name="215108633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108633">(Oct 30 2020 at 15:18)</a>:</h4>
<p><a href="https://github.com/rust-lang/docs.rs/pull/1143/files#diff-1f8c30ee3d5b1ac765c686840c3b659b0cb4fbc3245a0401f04eaaff939d8ae3R38-R40">https://github.com/rust-lang/docs.rs/pull/1143/files#diff-1f8c30ee3d5b1ac765c686840c3b659b0cb4fbc3245a0401f04eaaff939d8ae3R38-R40</a></p>



<a name="215108908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215108908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215108908">(Oct 30 2020 at 15:20)</a>:</h4>
<p>such that <code>failure</code> is never reached?</p>



<a name="215109017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215109017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215109017">(Oct 30 2020 at 15:21)</a>:</h4>
<p>well I didn't realize <code>resolve</code> was optional</p>



<a name="215109031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215109031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215109031">(Oct 30 2020 at 15:21)</a>:</h4>
<p>in our code it wasn't an <code>Option</code></p>



<a name="215109652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215109652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215109652">(Oct 30 2020 at 15:26)</a>:</h4>
<p>code that resolves to <code>Option</code> is abstracted away in the compiler, no?</p>



<a name="215111323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215111323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215111323">(Oct 30 2020 at 15:38)</a>:</h4>
<p>I don't understand the question</p>



<a name="215111342"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215111342" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215111342">(Oct 30 2020 at 15:39)</a>:</h4>
<p>the compiler can't check our types because this is in serialization</p>



<a name="215111369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215111369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215111369">(Oct 30 2020 at 15:39)</a>:</h4>
<p>the 'source of truth' is the documentation, not in rust code</p>



<a name="215111656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215111656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215111656">(Oct 30 2020 at 15:41)</a>:</h4>
<p>is there an expectation of a runtime cost to the <code>resolve</code> generating an <code>Option</code> type?</p>



<a name="215111865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215111865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215111865">(Oct 30 2020 at 15:42)</a>:</h4>
<p>no ,there's a correctness issue</p>



<a name="215111876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215111876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215111876">(Oct 30 2020 at 15:42)</a>:</h4>
<p>we weren't checking for null</p>



<a name="215112277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215112277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215112277">(Oct 30 2020 at 15:45)</a>:</h4>
<p>huh, <code>ok_or</code> seems to be doing that</p>



<a name="215112331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215112331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215112331">(Oct 30 2020 at 15:46)</a>:</h4>
<p>that's in the new code using cargo_metadata</p>



<a name="215112339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215112339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215112339">(Oct 30 2020 at 15:46)</a>:</h4>
<p>it wasn't htere before</p>



<a name="215112384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Tips%20to%20improve%20compile%20times%20within%20a%20crate%3F/near/215112384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Tips.20to.20improve.20compile.20times.20within.20a.20crate.3F.html#215112384">(Oct 30 2020 at 15:46)</a>:</h4>
<p>sorry it seemed like you linked to the update</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>